package com.example.demo.controller;

import com.example.demo.dao.JobDao;
import com.example.demo.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

// restful
// RestController=
@Controller
// 响应走  json
@ResponseBody

public class HelloController {

    @Autowired
    JobDao dao;

    // hello.action请求运行下面的方法
    /// hello.action?username=tom   @param username就有自动注入值了
    @RequestMapping("/hello.action")
    public Result hello(String username) {


        List<Map> a = dao.getjobavg();
        Result r = new Result();
        r.setCode(200);
        r.setMesage(" hello sucess ");
        r.setData(a);

        // {"code":200,"mesage":" hello sucess ","data":"tom"}
        return r;
    }
}
